package com.example.abstractFactoryPattern;

import com.example.abstractFactoryPattern.color.Color;
import com.example.abstractFactoryPattern.color.ColorFactory;
import com.example.abstractFactoryPattern.color.ColorType;
import com.example.abstractFactoryPattern.shape.Shape;
import com.example.abstractFactoryPattern.shape.ShapeFactory;
import com.example.abstractFactoryPattern.shape.ShapeType;

import java.util.Objects;

/**
 * 工厂的工厂
 * sun 2017-11-23
 */
public class FactoryProducer {
    public static AbstractFactory getFactory(FactoryType factoryType){
        if(Objects.isNull(factoryType)) return null;
        switch (factoryType){
            case COLOR:
                return new ColorFactory() {
                    @Override
                    public Color getColor(ColorType colorType) {
                        return super.getColor(colorType);
                    }
                };
            case SHAPE:
                return new ShapeFactory() {
                    @Override
                    public Shape getShape(ShapeType shapeType) {
                        return super.getShape(shapeType);
                    }
                };
            default:
                return null;
        }
    }
}
